﻿using UpdateControls.Correspondence;
using UpdateControls.Correspondence.Mementos;
using System.Collections.Generic;
using System.Linq;
using System;

namespace SurveySez.Model
{
	public partial class Survey
	{
		public string Question
		{
			get { return CurrentQuestions.Select(q => q.Question).FirstOrDefault(); }
			set { Community.AddFact(new SurveyQuestion(this, CurrentQuestions, value)); }
		}

		public Response NewResponse()
		{
			float maxOrder = Responses.Max(r => (float?)r.Order) ?? 0.0f;
			Response response = Community.AddFact(new Response(this));
			response.Order = maxOrder + 1.0f;
			return response;
		}
	}
}
